home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / decky.arc / SERIALKB.S < prev   
Text File  |  1989-06-15  |  5KB  |  129 lines

  1. start:
  2.          pea      install(pc)      ; superexec to set int vector
  3.          move.w   #38,-(a7)        ; and check for prior installation
  4.          trap     #14
  5.          addq.l   #6,a7
  6.          cmp.b    #1,d0
  7.          bne.s    bye
  8.          move.w   #-1,-(sp)        ; setup rs232 port
  9.          move.w   #-1,-(sp)
  10.          move.w   #-1,-(sp)
  11.          move.w   #-1,-(sp)
  12.          move.w   #0,-(sp)         ; no handshake
  13.          move.w   #2,-(sp)         ; 4800 baud
  14.          move.w   #15,-(sp)
  15.          trap     #14
  16.          add.l    #14,sp
  17. bye:     clr.w    -(a7)
  18.          move.l   #$400,-(a7)     ; reserve space, keep process
  19.          move.w   #$31,-(a7)
  20.          trap     #1
  21. install:
  22.          move.l   $130,a0         ; get the serial port int vector
  23.          movea.l  -4(a0),a1       ; check to see if serialkb installed
  24.          cmp.l    #$6b796264,a1
  25.          bne.s    hookit          ; no, install it
  26.          move.l   -8(a0),$130     ; yes, restore original vector
  27.          move.b   #0,d0
  28.          rts
  29. hookit:  move.l   a0,oldvec       ; save the original vector
  30.          pea      handler(pc)     ; and set the new vector
  31.          move.l   (a7)+,$130      ; pointer to rs232 in buf full intrpt
  32.          move.b   #1,d0
  33.          rts
  34. oldvec:  dc.l     0
  35. magic:   dc.b     'kybd'
  36. handler: 
  37.          movem.l  d0-d3/a0-a5,-(sp); save registers
  38.          lea      $fffffa01,a1     ; pointer to mfp
  39.          btst     #7,42(a1)        ; is it receive int
  40.          beq      done
  41.          clr.l    d0
  42.          move.b   46(a1),d0        ; get data
  43.          move.l   d0,d3
  44.          cmp.b    #$55,d0          ; ignore codes below $56
  45.          bls      done
  46.          cmp.b    #$8d,d0          ; prevent alt insert
  47.          bne.s    noinsr           ; to avoid crashing!
  48.          btst     #3,$e1b          ; is it alt?
  49.          beq      lookup           ; nope
  50.          bra      done             ; yes, toss it
  51. noinsr:  cmp.b    #$b4,d0          ; is it metronome?
  52.          bne.s    norept
  53.          move.l   oldkey,d0        ; repeat last key
  54.          bra      almost
  55. norept:  cmp.b    #$bf,d3          ; is it tilde - modify keyboard
  56.          bne.s    notilde
  57.          move.w   #$01,d0          ; make it esc
  58.          bra      almost
  59. notilde: cmp.b    #$c9,d3          ; is it <>
  60.          bne.s    nogtlt
  61.          move.w   #$29,d0          ; make it tilde
  62.          bra      almost
  63. nogtlt:  cmp.b    #$bc,d3          ; is it backsp
  64.          bne.s    notdel
  65.          btst     #0,$e1b          ; is it shifted
  66.          bne.s    notdel
  67.          move.w   #$53,d0          ; make it del
  68.          bra      almost
  69. notdel:  cmp.b    #$ad,d3          ; handle shift codes
  70.          bmi      lookup
  71.          cmp.b    #$bb,d3
  72.          bpl      lookup           ; nope
  73.          move.b   $e1b,d2          ; get shift mask
  74.          cmp.b    #$af,d3          ; is it shift
  75.          bpl.s    arnd1
  76.          eori.b   #3,d2            ; toggle shift bits
  77.          bra.s    arnd5
  78. arnd1:   cmp.b    #$b0,d3
  79.          bpl.s    arnd2
  80.          bchg     #2,d2            ; toggle ctrl bit
  81.          bra.s    arnd5
  82. arnd2:   cmp.b    #$b1,d3
  83.          bpl.s    arnd3
  84.          bchg     #4,d2            ; toggle caps lock bit
  85.          bra.s    arnd5
  86. arnd3:   cmp.b    #$b2,d3
  87.          bpl.s    arnd4
  88.          bset     #3,d2            ; set alt bit
  89.          bra.s    arnd5
  90. arnd4:   cmp.b    #$b4,d3          ; all ups
  91.          bpl.s    arnd5
  92.          andi.b   #$f0,d2          ; clear shift,ctrl, and alt bits
  93. arnd5:   move.b   d2,$e1b          ; save new shift status
  94.          bra.s    done
  95. lookup:  lea      table(pc),a0     ; convert dec to st scan code
  96.          sub.w    #$56,d3
  97.          and.l    #$ff,d3
  98.          asl.l    #1,d3
  99.          adda.l   d3,a0
  100.          move.w   (a0),d0
  101. almost:  move.l   #$db0,a0         ; point to kbd iorec addr
  102.          lea      $0,a5
  103.          move.l   d0,oldkey
  104.          jsr      $fc2aa6          ; get scan code in buffer
  105.          bclr     #3,$e1b          ; clear alt shift
  106. done:    bclr     #4,14(a1)        ; clear int service bit
  107.          movem.l  (sp)+,d0-d3/a0-a5; restore registers
  108.          rte
  109. table:   dc.w     $3b,$3c,$3d,$3e,$3f,0,0,0,0,0,0,0,0,0 ; function keys
  110.          dc.w     $40,$41,$42,$43,$44,0,0,0,0,0,0,0,0
  111.          dc.w     $54,$55,$56,$57,0,0,0,0,0,0,0   ; shifted funct keys
  112.          dc.w     $58,$59,0,0,$5a,$5b,$5c,$5d,0,0,0,0,0,0
  113.          dc.w     $62,$0e,$61,$52,$53,$47,0,0     ; keys abv cursor pad
  114.          dc.w     $70,0,$71,$72,$6d,$6e,$6f,$6a   ; numeric keypad
  115.          dc.w     $6b,$6c,$4e,$67,$68,$69,$4a
  116.          dc.w     $63,$64,$65,$66,0,0             ; pf keys
  117.          dc.w     $4b,$4d,$50,$48                 ; cursor keys
  118.          dc.w     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  119.          dc.w     $0e,$1c,$0f,$29,$02,$10,$1e,$2c,0 ; main keyboard
  120.          dc.w     $03,$11,$1f,$2d,0,0,$04,$12,$20,$2e
  121.          dc.w     0,$05,$13,$21,$2f,$39,0,$06,$14,$22,$30
  122.          dc.w     0,$07,$15,$23,$31,0,$08,$16,$24,$32,0
  123.          dc.w     $09,$17,$25,$33,0,$0a,$18,$26,$34,0
  124.          dc.w     $0b,$19,0,$27,$35,0,$0d,$1b,$2b,0
  125.          dc.w     $0c,$1a,$28,0,0,0
  126. oldkey:  dc.l     0
  127.          end
  128.  
  129.